// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

const int N = 1e3+50, M = N * N;


struct ios {
    inline char read(){
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }

    template <typename _Tp> inline ios & operator >> (_Tp&x){
        static char c11,boo;
        for(c11=read(),boo=0;!isdigit(c11);c11=read()){
            if(c11==-1)return *this;
            boo|=c11=='-';
        }
        for(x=0;isdigit(c11);c11=read())x=x*10+(c11^'0');
        boo&&(x=-x);
        return *this;
    }

    int read(char *s) {
        int len = 0;
        char ch;
        for (ch=read(); ch=='\n' || ch == ' '; ch=read());
        if (ch == -1) {
            s[len] = 0;
            return -1;
        }
        for (; ch!='\n' && ch != ' ' && ch != -1;ch=read())
            s[len++] = ch;
        s[len] = 0;
        return len;
    }
} io;

int t, n, m;
typedef pair<int, int> P;
P mp[N][N];

inline int id(int i, int j) {
    return (i-1) * n + j;
}

vector<int> G[M];
inline void add(int u, int v) {
    G[u].push_back(v);
    // G[v].push_back(u);
}

const int dx[] = {-1, 1, 0, 0},
dy[] = {0, 0, 1, -1};

inline pair<int, int> trans(int id) {
    P res(id / n + 1, id % n);
    if (res.second == 0) {
        --res.first;
        res.second = n;
    }
    return res; 
}

char ans[N][N];

char conduct(P l, P r) {
    if (l.first + 1 == r.first)
        return 'D';
    else if (l.first - 1 == r.first)
        return 'U';
    else if (l.second + 1 == r.second)
        return 'R';
    else
        return 'L';
}
bool vis[M];
void dfs(int u, int fa, vector<P> &path) {
    // dbg(u);
    path.push_back(trans(u));
    vis[u] = true;
    for (int v : G[u]) {
        if (v == fa) continue;
        P pv = trans(v);
        if (~mp[pv.first][pv.second].first)
            continue;
        if (vis[v]) {

        } else {
            dfs(v, u, path);
        }
    }

    path.pop_back();
    P p = trans(u);
    if (path.size())
        ans[p.first][p.second] = conduct(p, path.back());
}

int main(int argc, char const *argv[]) {
    // code
    io >> n;
    queue<int> Q;
    for (int i=1; i<=n; ++i)
        for (int j=1; j<=n ;++j) {
            io >> mp[i][j].first >> mp[i][j].second;
            for (int r=0; r<4; ++r)
            {
                int tx = dx[r] + i, ty = dy[r] + j;
                if (1 <= tx && tx <= n && 1 <= ty && ty <= n)
                    add(id(i, j), id(tx, ty));
            }
            if (mp[i][j].first == i && mp[i][j].second == j) {
                ans[i][j] = 'X';
                Q.push(id(i, j));
            }
        }

    while (!Q.empty()) {
        int now = Q.front(); Q.pop();
        // dbg(now);
        P p = trans(now);
        for (int v : G[now])
        {
            P pv = trans(v);
            if (ans[pv.first][pv.second] || mp[pv.first][pv.second] != mp[p.first][p.second])
                continue;
            if (~mp[pv.first][pv.second].first) {
                ans[pv.first][pv.second] = conduct(pv, p);
                Q.push(v);
            }
        }
    }
    bool suc = true;
    for (int i=1; i<=n && suc; ++i)
        for (int j=1; j<=n; ++j) {
            if (~mp[i][j].first && !ans[i][j]) {
                suc = false;
                break;
            }
        }
    if (!suc) {
        puts("INVALID");
        return 0;
    }
    for (int i=1; i<=n * n; ++i) {
        if (!vis[i]) {
            P p = trans(i);
            if (~mp[p.first][p.second].first)
                continue;
            int fd = -1;
            for (int v : G[i]) {
                P pv = trans(v);
                if (~mp[pv.first][pv.second].first)
                    continue;
                fd = v;
                break;
            }
            if (fd == -1) {
                suc = false;
                break;
            }

            P pv = trans(fd);
            ans[p.first][p.second] = conduct(p, pv);
            ans[pv.first][pv.second] = conduct(pv, p);
            vis[i] = vis[fd] = true;
            vector<P> path;
            dfs(i, -1, path);
            path.clear();
            dfs(fd, -1, path);

        }
    }
    if (!suc) {
        puts("INVALID");
        return 0;
    }
    puts("VALID");
    for (int i=1; i<=n; ++i)
        printf("%s\n", ans[i] + 1);


    return 0;
}

 